package com.tanhua.server.controller;

import com.tanhua.model.vo.QuestionnaireVo;
import com.tanhua.model.vo.TestResultVo;
import com.tanhua.server.service.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author fff
 * @date 2021/12/11 11:27
 **/
@RestController
@RequestMapping("/testSoul")
public class TestSoulController {

    @Autowired
    private TestSoulService testSoulService;

    //问卷列表
    @GetMapping
    public ResponseEntity questionnaireList(){

      List<QuestionnaireVo> vos= testSoulService.questionnaireList();


        return ResponseEntity.ok(vos);
    }

    //提交问卷答案
    @PostMapping
    public ResponseEntity commit(@RequestBody Map map ){
       String id = testSoulService.commit(map);
       return ResponseEntity.ok(id);
    }


    //查看

    @GetMapping("report/{id}")
    public ResponseEntity lookResult(@PathVariable String id){

      TestResultVo testResultVo = testSoulService.lookResult(id);


        return ResponseEntity.ok(testResultVo);
    }


}
